#ifndef ENTITY_H
#define ENTITY_H

#include "utilities.h"
#include <QVector2D>
#include <QList>
#include <QMap>
#include <QColor>
#include <QTime>

class Game;

class Entity
{
public:
   Entity(const quint32 ID=0);
   virtual ~Entity();

   typedef QList<Entity*> EntityListType;
   typedef QMap<quint32, Entity *> EntityMapType;

   virtual ENTITY_TYPE type();

   virtual quint32 id();
   virtual void setID(const quint32 id);

   virtual quint32 playerID();
   virtual void setPlayerID(const quint32 playerID);

   virtual bool active();
   virtual void setActive(const bool active);

   virtual bool updated();
   virtual void setUpdated(const bool updated);

   virtual QVector2D position();
   virtual void setPosition(const QPointF &pos);

   virtual QVector2D velocity();
   virtual void setVelocity(const QPointF &vel);

   virtual QVector2D acceleration();
   virtual void setAcceleration(const QPointF &accel);

   virtual qreal rotation();
   virtual void setRotation(const qreal rotation);

   virtual EntityBaseStats baseStats();
   virtual void setBaseStats(const EntityBaseStats &stats);

   virtual qint32 kind();
   virtual void setKind(const qint32 kind);

   virtual qint32 size();
   virtual void setSize(const qint32 size);

   virtual QRgb color();
   virtual void setColor(const QRgb color);

   virtual qint32 health();
   virtual void setHealth(const qint32 health);

   virtual Entity* target();
   virtual void setTarget(Entity *target);

   virtual quint32 squadID();
   virtual void setSquadID(const quint32 id);

   virtual QTime nextThinkTime();
   virtual void setNextThinkTime(const QTime &time);

   virtual void setGame(Game *game);

   virtual void tick(const qreal timeDelta) = 0;
   virtual void think() = 0;

   virtual void onAddToGame();

   virtual void marshall(const EVENT_TYPE event, QDataStream &data);
   virtual void demarshall(const EVENT_TYPE event, QDataStream &data, const quint32 playerID=0);

protected:
   quint32     mID;
   quint32     mPlayerID;
   bool        mActive;
   bool        mUpdated;
   QVector2D   mPosition;
   QVector2D   mVelocity;
   QVector2D   mAcceleration;
   qreal       mRotation;
   EntityBaseStats mBaseStats;
   qint32      mHealth;

   Game       *mGame;
   QTime       mNextThinkTime;

   Entity     *mTarget;

   quint32     mSquadID;

};

#endif // ENTITY_H
